package com.rainng.coursesystem.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@TableName("rc_answer")
@Data
public class AnswerEntity {
    public static final String ID = "id";
    public static final String STUDENT_ID = "student_id";
    public static final String HOMEWORK_ID = "homework_id";
    public static final String DESCRIPTION = "description";
    public static final String CREATE_TIME = "create_time";
    public static final String PATH = "path";
    public static final String GRADE = "grade";

    @NotNull
    @TableId(value = ID, type = IdType.AUTO)
    private Integer id;

    @NotNull(message = "学生ID不能为空")
    @TableField(STUDENT_ID)
    private Integer studentId;

    @NotNull(message = "作业ID不能为空")
    @TableField(HOMEWORK_ID)
    private Integer homeworkId;

    @Length(max = 255, message = "描述长度不能超过255个字符")
    @TableField(DESCRIPTION)
    private String description;

    @NotNull(message = "创建时间不能为空")
    @TableField(CREATE_TIME)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Length(max = 255, message = "路径长度不能超过255个字符")
    @TableField(PATH)
    private String path;

    @TableField(GRADE)
    private String grade;
}    